<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="java.util.Date" %><%--为了浏览器不发生多次重定向错误--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>你看不到我👍</title>
</head>
<body>
<%String path = application.getContextPath();

    Cookie[] cookies = request.getCookies();
    if (cookies!=null){
        for (Cookie cookie : cookies) {
            if("rememberme".equals(cookie.getName())){
                String value = cookie.getValue();
                Long timeLong = Long.valueOf(value);
                String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date(timeLong));
                request.getSession().setAttribute("time",time);

                session.setAttribute("username","admin");

                response.sendRedirect(path+"/index.jsp");
                return;
            }
        }
    }
    response.sendRedirect(path+"/login.jsp");

%>
</body>
</html>
